import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en' // lang i18n
import i18n from '@/lang'

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control
import Component from '@/components' // 导入自己的组件进行全局注册

// import checkPermission from '@/mixin/checkPermission'
// Vue.mixin(checkPermission)

import checkPermission from '@/mixin/checkPermission'
Vue.use(checkPermission)

// 导入过滤器
import * as filters from '@/filters'
// 注册全局过滤器
Object.keys(filters).forEach(key => {
  // 注册过滤器
  Vue.filter(key, filters[key])
})

Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

Vue.config.productionTip = false

// 导入 + 注册自定义指令
import * as directives from '@/directives'
Object.keys(directives).forEach(item => {
  // Vue.directive(item, {
  //   // 当被绑定的元素插入到 DOM 中时……
  //   inserted: directives[item]
  // })
  Vue.directive(item, directives[item])
})
import moment from 'moment' // 全局注册moment
Vue.use(moment)

// 导入 + 注册打印插件
import Print from 'vue-print-nb'
Vue.use(Print)

Vue.use(Component) // 注册自己的插件

// 设置element为当前的语言
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
